layui.use(['form', 'admin', 'layer', 'func', 'ax', 'laydate', 'upload', 'formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;
    var func = layui.func;

    //渲染时间选择框
    var laydate = layui.laydate;
    laydate.render({
        elem: '#moveDate' //指定元素
    });

    /*//表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/warehouseMove/addItem", function (data) {
            Feng.success("添加成功！");
            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);
            //关掉对话框
            admin.closeThisDialog();
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });*/

    //初始化仓库列表
    $.ajax({
        url: '/baseCommonSelect/initWarehouseInfos',
        dataType: 'json',
        data: {"enumCode": "WarehouseType"},
        type: 'post',
        success: function (data) {
            if (data !== null) {
                //移入仓库
                $("#moveInWarehouse").empty();
                $("#moveInWarehouse").append(new Option());
                $.each(data, function (index, item) {
                    $('#moveInWarehouse').append(new Option(item.value, item.id));
                });
                //移出仓库
                $("#moveOutWarehouse").empty();
                $("#moveOutWarehouse").append(new Option());
                $.each(data, function (index, item) {
                    $('#moveOutWarehouse').append(new Option(item.value, item.id));
                });
            } else {
                $("#moveInWarehouse").append(new Option("暂无数据", ""));
                $("#moveOutWarehouse").append(new Option("暂无数据", ""));
            }
            //重新渲染
            form.render("select");
        }
    });

    /*//下一步按钮点击 弹出对话框
    $('#btnNext').click(function () {
        var moveType = $("#moveType option:selected").val();
        var moveInWarehouse = $("#moveInWarehouse option:selected").val();
        var moveOutWarehouse = $("#moveOutWarehouse option:selected").val();
        var moveInWarehouseName = $("#moveInWarehouse option:selected").text();
        var moveOutWarehouseName = $("#moveOutWarehouse option:selected").text();
        // location.href = Feng.ctxPath +'/warehouseMove/initProductList';
        func.openDlg({
            title: '移货商品明细添加',
            content: Feng.ctxPath + '/warehouseMove/initProductList?moveType=' + moveType + "&moveInWarehouse=" + moveInWarehouse + "&moveOutWarehouse=" + moveOutWarehouse+ "&moveOutWarehouseName=" + moveOutWarehouseName+ "&moveInWarehouseName=" + moveInWarehouseName,
            // area ： 【'宽','高'】
            area: ['1000px', '600px'],
            height:1000,
            skin: 'layui-layer-molv',
        });
    });*/

    form.on('submit(btnSubmit)', function (data) {
        var moveType = $("#moveType option:selected").val();
        var moveInWarehouse = $("#moveInWarehouse option:selected").val();
        var moveOutWarehouse = $("#moveOutWarehouse option:selected").val();
        var moveInWarehouseName = $("#moveInWarehouse option:selected").text();
        var moveOutWarehouseName = $("#moveOutWarehouse option:selected").text();
        // location.href = Feng.ctxPath +'/warehouseMove/init';
        func.openDlg({
            title: '移货商品明细添加',
            content: Feng.ctxPath + '/warehouseMove/initProductList?moveType=' + moveType + "&moveInWarehouse=" + moveInWarehouse + "&moveOutWarehouse=" + moveOutWarehouse+ "&moveOutWarehouseName=" + moveOutWarehouseName+ "&moveInWarehouseName=" + moveInWarehouseName,
            // area ： 【'宽','高'】
            area: ['1000px', '600px'],
            height:1000,
            skin: 'layui-layer-molv',
        });
    });

});